<?php
namespace app\admin\controller;

use think\Controller;

use app\admin\controller\Base;

use think\Db;
use think\Session;
//评论
//删 查 列表
class Comment extends Base
{
   public function lst()
   {
       $com=db('comment')->alias('c')->join('user u','u.user_id=c.user_id')->join('goods g','g.goods_id=c.goods_id')->where('goods_status=0')->select();
       $this->assign('info',$com);
       return $this->fetch();
   }

   public function log()
   {
       $com=db('comment')->alias('c')->join('log l','l.log_id=c.log_id')->join('user u','u.user_id=c.user_id')->where('log_status=0')->select();       
       $this->assign('info',$com);
       return $this->fetch();
   }

   public function del()//删除评论
   {  
       $daily_id=input('comment_id');
       $del=db('comment')->where('comment_id',$daily_id)->delete();
       if($del)
       {
           return $this->success('删除评论成功！');
       }
       else
       {
           return $this->error('删除评论失败');
       }
   }

   public function checkstatus()//改变评论状态 
   {
       $daily_id=input('comment_id');
       $daily_status=db('comment')->where('comment_id',$daily_id)->field('comment_status')->find();
       if($daily_status['comment_status']==0)
       {
           $daily_statusl=['comment_status'=>1];
           
           $res=db('comment')->where("comment_id",$daily_id)->update($daily_statusl);
           if($res)
           {
               return $this->success('您已经冻结评论成功','lst');//跳转到用户列表页
           }
           else{
               return $this->error('您冻结评论失败!');
       }
       }
   }
}